/**
 * Created by root on 17-4-10.
 */
var fs = require('fs');

var readStream = fs.createReadStream('stream_event.js');
var writeStream = fs.createWriteStream('stream_event_stream.js');

readStream.on('data', function (chunk) {
    if(writeStream.write(chunk) === false) {
        readStream.pause();
    }
});

readStream.on('end', function () {
    writeStream.end();
});

writeStream.on('drain', function () {
    readStream.resume();
});